<script>
	export default {
		onLaunch: function() {
			// console.log('App Launch')
			// this.versionCheck()
			uni.setStorage({
				key: 'socket_state',
				data: 'closed',
				success: function () {
					console.log('success');
				}
			});
		},
		onShow: function () {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		},
		methods: {
			/**
			 * 版本号检查
			 */
			async versionCheck () {
				let res = await this.http.request({
					url: '/api/version/check',
					method: 'post',
					isLoadding: false,
					data: {
						version: '1.0' //打包前先设置版本号
					}
				})
				if (res.status == 1 && res.data.id) {
					uni.showModal({
						title: '版本更新',
						content: res.data.content,
						confirmText: '更新',
						showCancel: !res.data.enforce,
						success: (res2) => {
							if (res2.confirm) {
								plus.runtime.openURL(res.data.downloadurl)
							}
						}
					})
				}
			}
		}
	}
</script>

<style>
</style>
